{use master_page('admin/v_master')} 

{block content}

<?php $ci = &get_instance(); 
function bl_class($children,$level=1)
{
	$ci = & get_instance();
	foreach($children as $child)
	{
		$title = $child->title;
		$pad = "";
		if($level>1)
		{
			for($i=0;$i<$level-1;$i++)
			{
				$pad = $pad . "&nbsp;&nbsp;";
			}
			$pad = $pad."└";
		}
		if($level == 1){
		$pad="";
		}
		// $title = str_pad($title,'-',strlen($title)+level,STR_PAD_LEFT);

		echo "<option value='".$child->id."'>$pad$title</option>" ;
		if(sizeof($child->children)>0)
		{
			bl_class($child->children,$level+1);
		}
	}
}
?>

<div class="line"> 
<form action="<?=$_SERVER['REQUEST_URI']?>" method="post">
<div class="blank20" style="height:20px"></div>
	<div id="tagscontent" class="right_box">
	<table class="formtable" style="border:0px solid #cfcfcf;width:100%">
		<tr class='form_line'>
			<td class='title' width='15%'><?=lang('article_title')?></td>
			<td class='content'>
				<input name='p_title' size='48' value='<?=set_value('p_title', $title)?>' type='text' />  
				<?=form_error('p_title', '<font color="red">', '</font>')?>  
			</td>
		</tr>
		<tr class='form_line'>
			<td class='title'><?=lang('article_content')?></td> 
			<td class='content'>
				<textarea name='p_content' id='content'><?=set_value('p_content', $content)?></textarea>  
				<?=form_error('p_content', '<font color="red">', '</font>')?>   
			</td>
		</tr>
		<tr class='form_line'>
			<td class='title'><?=lang('article_from')?></td>
			<td class='content'>
				<input name='p_from' size='30' value='<?=set_value('p_from', (($from=='')?($site_info->name):$from))?>' type='text' />    
				<?=form_error('p_from', '<font color="red">', '</font>')?>  
			</td>
		</tr>
		<tr class='form_line'>
			<td class='title'><?=lang('article_author')?></td>
			<td class='content'>
				<input name='p_author' size='30' value='<?=set_value('p_author', (($author=='')?($this->current_user()->nickname):$author))?>' type='text' />  
				<?=form_error('p_author', '<font color="red">', '</font>')?>  
			</td>
		</tr>
		<tr class='form_line'>
			<td class='title'><?=lang('article_click_count')?></td>
			<td class='content'>
				<input name='p_click_count' size='6' value='<?=set_value('p_click_count', empty($click_count)?0:$click_count)?>' type='text' />  
				<?=form_error('p_click_count', '<font color="red">', '</font>')?>  
			</td>
		</tr>
		<?$cls = $this->article_class_manager->get($this->input->get('class_id'));?>
		<?$children = 
			!empty($_GET['class_id'])?$cls->children:$this->article_class_manager->get_root_list();?>
		<?if(sizeof($children)>0):?>
		<tr class='form_line'> 
			<td class='title'><?=lang('article_class')?></td>
			<td class='content'>
				<select id = 'class_id' class='bind'>
					<option value="">请选择</option>
					<?php if(!empty($_GET['class_id'])):?>
					<option value='{cls->id}'>{cls->title}</option>  
					<?php endif;?>
					<?php bl_class($children,1)?>
				</select>  
				<input name='p_class_id' value='<?=set_value('p_class_id', $class_id)?>' type='hidden' />   
				<?=form_error('p_class_id', '<font color="red">', '</font>')?>   
			</td>
		</tr>
		<?else:?>
		<input name='p_class_id' value='<?=set_value('p_class_id', $class_id)?>' type='hidden' /> 
		<?endif;?>
	</table>
	</div>
		<div class="blank20"style="height:20px"></div>
		<input type="submit" name="submit" value=" 提交 " class="btn_a">
</form>
</div> 
<script>
$(document).ready(function(){
<?php
$editor = "UEditor";  
$editor = "KindEditor"; 
if($editor == "KindEditor"): 
?>
var editor;
KindEditor.ready(function(K) {
	editor = K.create('#content',{allowFileManager : true,width:"598px",height:"420px"}) ;      
});
<?php else:?>

var ue = new UE.ui.Editor();
ue.options.UEDITOR_HOME_URL = "<?php echo _V("scripts/ueditor/")?>";
ue.render('content');

<?php endif;?>

});
</script>

{end}



